package edu.gd.mvndemo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/a")
public class Hello extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    //super.doGet(req, resp);
        resp.setContentType("text/html");
        String user=req.getParameter("user");
        String password=req.getParameter("password");
        //设置cookie
        //Cookie cookie=new Cookie("username","123"+user);
        //cookie.setMaxAge(60*60*24);
        //resp.addCookie(cookie);
       // PrintWriter out=resp.getWriter();
        //out.write("name="+cookie.getName()+"value="+cookie.getValue());
        // 跳转
        //if(user.equals("admin")&&password.equals("123"))
          //  req.getRequestDispatcher("houtai.jsp").forward(req, resp);
        //else
          //  req.getRequestDispatcher("index.jsp").forward(req,resp);
    }
}
